package com.chy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.chy.common.CustomException;
import com.chy.common.R;
import com.chy.entity.Chat;
import com.chy.mapper.CategoryMapper;
import com.chy.mapper.ChatMapper;
import com.chy.service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatServiceImpl  extends ServiceImpl<ChatMapper, Chat> implements ChatService {
    @Autowired
    ChatMapper chatMapper;

    @Override
    public boolean save(Chat chat) {
        return super.save(chat);
    }


    @Override
    public R<Chat> getChatStatus(Chat chat) {
        LambdaQueryWrapper<Chat> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Chat::getIsAgree, chat.getIsAgree());
        return R.success(this.getOne(wrapper));
    }

    @Override
    public R<List<Chat>> getChatStatus2(Chat chat) {
        LambdaQueryWrapper<Chat> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Chat::getChat, chat.getChat());
        return R.success(this.list(wrapper));
    }
}
